//package org.ricks.robot.business;
//
//import org.ricks.common.utils.RandomUtils;
//import org.ricks.net.transport.kcp.KcpSession;
//import org.ricks.protocol.ByteBuf;
//import org.ricks.robot.Monitor;
//import org.ricks.robot.RobotInfo;
//import org.ricks.robot.RobotManager;
//import org.ricks.robot.RobotRun;
//import org.ricks.robot.action.RobotGachaCmdAction;
//import proto.common.FProto;
//import proto.common.PBGacha;
//import proto.common.PBPlayer;
//
//import java.util.concurrent.TimeUnit;
//
//
//public class RobotGachaAction {
//
//    public static RobotGachaCmdAction robotGachaCmdAction = (session, gachaId) -> {
//
//    };
//
//
//    public static void gacha(KcpSession session, int gachaId ,  int  runCount) {
//        for (int i = 0; i < runCount ; i++) {
//            gacha(session, gachaId);
//        }
//    }
//
//    public static void gacha(KcpSession session, int gachaId ) {
////        long gachaTime = RobotAction.taskTimes.get(session) + 3000;
////        RobotRun.scheduledExecutorService.schedule(() -> RobotAction.addItem(session, 104, 1), gachaTime, TimeUnit.MILLISECONDS);
//        int randomTime = RandomUtils.randomInt(1000, 5000);
//        RobotRun.scheduledExecutorService.schedule(() -> {
//            Monitor.addActionRequest(session, FProto.Action.Gacha);
//            RobotInfo robotInfo = RobotManager.get(session);
//            robotInfo.requestTimeMap.put(FProto.Action.Gacha, System.currentTimeMillis());
//            PBGacha pbGacha = PBGacha.newBuilder()
//                    .setGachaId(gachaId)
//                    .setGachaType(PBGacha.PBGachaType.Single)
//                    .build();
//
//            PBPlayer pbPlayer = PBPlayer.newBuilder()
//                    .addGachaArray( pbGacha)
//                    .build();
//
//            FProto fProto = FProto.newBuilder()
//                    .setKey(FProto.Key.Player)
//                    .setAction(FProto.Action.Gacha)
//                    .setSelf(pbPlayer)
//                    .build();
//
//            byte[] data = fProto.toByteArray();
//
//            ByteBuf buf = new ByteBuf(1024);
//            buf.writeByte((byte) 0x03);
//            buf.writeBytes(data);
//            robotInfo.gacha1Count ++;
//            session.send(buf.toArray());
//            }, randomTime,TimeUnit.MILLISECONDS);
//
//    }
//
//    public static void gacha10(KcpSession session, int gachaId ,  int  runCount) {
//        for (int i = 0; i < runCount ; i++) {
//            gacha10(session,gachaId);
//        }
//
//    }
//
//    public static void gacha10(KcpSession session, int gachaId ) {
////        long gachaTime = RobotAction.taskTimes.get(session) + 3000;
////        RobotRun.scheduledExecutorService.schedule(() -> RobotAction.addItem(session, 104, 10), gachaTime, TimeUnit.MILLISECONDS);
////        gachaTime += 5000;
//
//        int randomTime = RandomUtils.randomInt(1000, 5000);
//
//        RobotRun.scheduledExecutorService.schedule(() -> {
//            Monitor.addActionRequest(session, FProto.Action.Gacha);
//            RobotInfo robotInfo = RobotManager.get(session);
//            robotInfo.requestTimeMap.put(FProto.Action.Gacha, System.currentTimeMillis());
//            PBGacha pbGacha = PBGacha.newBuilder()
//                    .setGachaId(gachaId)
//                    .setGachaType(PBGacha.PBGachaType.TenTimes)
//                    .build();
//
//            PBPlayer pbPlayer = PBPlayer.newBuilder()
//                    .addGachaArray(pbGacha)
//                    .build();
//
//            FProto fProto = FProto.newBuilder()
//                    .setKey(FProto.Key.Player)
//                    .setAction(FProto.Action.Gacha)
//                    .setSelf(pbPlayer)
//                    .build();
//
//            byte[] data = fProto.toByteArray();
//
//            ByteBuf buf = new ByteBuf(1024);
//            buf.writeByte((byte) 0x03);
//            buf.writeBytes(data);
//            robotInfo.gacha10Count ++;
//            session.send(buf.toArray());
//        },randomTime,TimeUnit.MILLISECONDS);
//    }
//
//    public static void startGachaTask(KcpSession session) {
//        RobotInfo robotInfo = RobotManager.get(session);
//        robotInfo.action = FProto.Action.Gacha;
//        RobotAction.addItem(session, 104, 100000000);
////        gacha(session, 1000,  runCount);
////        gacha10(session, 1000 , runCount);
////
////        gacha(session, 1001,  runCount);
////        gacha10(session, 1001 , runCount);
//    }
//}
